<template>
  <div class="container">
    <el-tabs
      v-model="activeName"
      style="margin-top: 15px"
      type="border-card"
      tab-click = "change"
    >
      <el-tab-pane
        v-for="item in tabMapOptions"
        :key="item.key"
        :label="item.label"
        :name="item.key"
      >
        <HomeworkTable
          v-if="activeName == item.key"
          :state = "activeName"
        />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import { defineComponent, reactive, toRefs, onMounted} from 'vue'
import { useRoute, useRouter } from 'vue-router'
import HomeworkTable from './components/HomeworkTable.vue'
export default defineComponent({
  components: {
    HomeworkTable
  },
  setup() {
    const route = useRoute()
    const dataMap = reactive({
      route: route,
      router: useRouter(),
      tabMapOptions: [
        { label: '已批阅', key: 'corrected' },
        { label: '未批阅', key: 'uncorrected' }
      ],
      activeName: 'uncorrected'
    })
    onMounted(() => {
    })
    // watch(() => dataMap.activeName, (s) => {
    //   dataMap.router
    //     .push(`${dataMap.route.path}?state=${s}`)
    //     .catch((err) => {
    //       console.warn(err)
    //     })
    // })
    return { ...toRefs(dataMap) }
  },
  mounth() {
  }
})
</script>

<style scoped>
.container {
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}

.tab-container {
  margin: 30px;
}
</style>
